//tokens.h
//Header file for the tokenizer team
//Authors: Matthew Lorenzo and Daniel Diaz

//History:
// 2/15/12 - Created Header file and function/structure declarations in C. Will change to classes/vectors as soon as I get more familiar with C++ (Matthew Lorenzo)
// 2/22/12 - Attempted to convert header files (struct to class) in a format more suitable with C++ code. Still need to learn about vectors some more (Matthew Lorenzo)
// 2/27/12 - With the help of Sam, Daniel and I (matt) refined our header file to define the classes and functions of those clases. Also included a char in the Tokens class to help Identify the token type. 
//Still needs to be tested

#ifndef TOKENS_H
#define TOKENS_H

#include <iostream>
#include <vector>
#include <string>
#include <fstream.h>

using namespace std;

//Declaring Tokens and TokensHeader class
class Tokens;
class TokensHeader;

//Defining Tokens class
class Tokens
        {
        string *token;
		unsigned int linenumber;  
		string *filename;   //linenumber and filename associated with token
        char type; //indicator for the type of token
            //u= unknown, l= label, d=directive, r=register, c=comment, a=open parenthesis, b=close parenthesis, z=comma
		public:
		{
		Tokens(string x,unsigned int y,string z,char a);
          	token= new string(x);
                filename= new string(z);
                linenumber=y;
                type=a;
            }
			~Tokens()
            {
                delete token;
                delete filename;
            }
            string *ret_token()
            {
                return this->token;
            }
            string *ret_filename()
            {
                return this->filename;
            }
            unsigned int ret_linenumber()
            {
                return this->linenumber;
            }
            char ret_type()
            {
                return this->type;
            }
		};

class TokensHeader
	{
		vector<Tokens> *tokenlist;
		unsigned int linenumber; //current linenumber
		string *filename;		//current file
		
	public:
	{	
	TokensHeader(string *file) //constructor
            linenumber=0;
            tokenlist= new vector<Tokens>;
            filename= new string;
            filename=file;
            
        }
		~TokensHeader()
        {
            delete tokenlist;
            delete filename;
        }
		void AppendToken(string x,unsigned int y, string z, char a);
        {
            
            Token=Tokens(x,y,z,a);
            tokenlist.push_back(Token);
        }
		void SetLine(unsigned int x)
        {
            this->linenumber=x;
        }
		unsigned int GetLinenum()
        {
            return this->linenumber;
        }
        void LineReset()
        {
            this->linenumber=0;
        }
        void IncLine()
        {
            this->linenumber++;
        }
		void SetFileName(string x)
        {
            this->filename=x;
        }
		void Set_TokenList(vector<Tokens> *x)
        {
            this->tokenlist=x;
        }
        vector<Tokens>* GetTokens()
        {
            return this->tokenlist;
        }
	};

//Tokenizing function declaration
vector<Tokens>* Tokenize(string,vector<Tokens>*);



#endif

